package com.servicesystem.servicesystem.controller;


import com.baomidou.mybatisplus.extension.api.ApiController;
import com.servicesystem.servicesystem.entity.AliOrderLogistics;
import com.servicesystem.servicesystem.service.AliOrderLogisticsService;
import com.servicesystem.servicesystem.untis.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (AliOrderLogistics)表控制层
 *
 * @author makejava
 * @since 2020-09-16 16:48:36
 */
@RestController
@RequestMapping("aliOrderLogistics")
public class AliOrderLogisticsController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private AliOrderLogisticsService aliOrderLogisticsService;

    @PostMapping("add-logistics")
    public R addLogistics(@RequestBody AliOrderLogistics aliOrderLogistics) {
        aliOrderLogisticsService.save(aliOrderLogistics);
        return R.success();
    }

    @PutMapping("fix-logistics")
    public R fixLogistics(String aliOrderId, String logisticsId, String logisticsName) {
        aliOrderLogisticsService.fixLogistics(aliOrderId, logisticsId, logisticsName);
        return R.success();
    }

    /***********************************字节需要*************************************/

    /***
     * 根据orderId查询ali订单物流表
     * @return
     */
    @GetMapping("/getLogisticsAdd/{orderId}")
    public R getLogisticsAdd(@PathVariable(value = "orderId") String orderId) {
        AliOrderLogistics aliOrderLogistics = aliOrderLogisticsService.getLogisticsAdd(orderId);
        return R.success(aliOrderLogistics);
    }

    /***
     * 查询全部ali订单物流列表
     * @return
     */
    @GetMapping("/getLogisticsList")
    public R getLogisticsList() {
        List<AliOrderLogistics> aliOrderLogistics = aliOrderLogisticsService.getLogisticsList();
        return R.success(aliOrderLogistics);
    }

    /***
     * 根据阿里订单id获取数据
     * @param AliOrderId
     * @return
     */
    @GetMapping("/getLogisticsByAliOrderId")
    public R getLogisticsByAliOrderId(@RequestParam String AliOrderId) {
        AliOrderLogistics aliOrderLogistic = aliOrderLogisticsService.getLogisticsByAliOrderId(AliOrderId);
        return R.success(aliOrderLogistic);
    }
}
